package nc.bs.pub.action;

import com.alibaba.fastjson.JSONObject;

import jdk.nashorn.api.scripting.JSObject;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.action.listener.ISamplingServer;
import nc.bs.pub.compiler.AbstractCompiler2;
import nc.itf.qc.c007.approve.ISamplingApprove;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pubapp.pub.power.PowerActionEnum;
import nc.vo.qc.c007.entity.SamplingVO;
import nc.vo.scmpub.res.billtype.QCBillType;
import nc.vo.uap.pf.PFBusinessException;
import nccloud.vo.scmpub.utils.power.DataPermissionUtil;

public class N_C007_APPROVE extends AbstractCompiler2 {
	public String getCodeRemark() {
		return "\t\n      Object retValue = null;\n      nc.vo.qc.c007.entity.SamplingVO[] inObject = (nc.vo.qc.c001.entity.SamplingVO[]) getVos();\n      \n      retValue = nc.bs.framework.common.NCLocator.getInstance().lookup(nc.itf.qc.c007.approve.ISamplingApprove.class)\n          .approveSampling(inObject, this);\n      \n      return retValue;\n";
	}

	public Object runComClass(PfParameterVO vo) throws BusinessException {
		try {
			super.m_tmpVo = vo;
			Object retValue = null;
			SamplingVO[] inObject = (SamplingVO[]) ((SamplingVO[]) this.getVos());
			if (vo.isCloudEntry) {
				DataPermissionUtil.checkPermission(inObject, QCBillType.SamplingBill.getCode(),
						PowerActionEnum.APPROVE.getActioncode(), "vbillcode");
			}
		    if (inObject[0].getBVO()[0].getVbdef1()!=null&&!inObject[0].getBVO()[0].getVbdef1().equals("0")) {
		    	 NCLocator.getInstance().lookup(ISamplingServer.class).approve(inObject);
		   	    }
			retValue = ((ISamplingApprove) NCLocator.getInstance().lookup(ISamplingApprove.class))
					.approveSampling(inObject, this);

			return retValue;
		} catch (Exception var4) {
			if (var4 instanceof BusinessException) {
				throw (BusinessException) var4;
			} else {
				throw new PFBusinessException(var4.getMessage(), var4);
			}
		}
	}
}